﻿<UserControl x:Class="FSquirrel.Views.SettingsView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ignore="http://www.ignore.com" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF45"
             xmlns:Properties="clr-namespace:FSquirrel.Properties" mc:Ignorable="d ignore"
             DataContext="{Binding SettingsVM, Source={StaticResource Locator}}">

    <Grid Opacity="1" Background="{x:Null}">
        <Rectangle x:Name="MainRectangle" Margin="0,0,0,0" Style="{DynamicResource UserControlOverlayRectangleStyle}"/>
        <Grid Width="400" Height="480" Background="{x:Static SystemColors.WindowBrush}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="162*" />
                <ColumnDefinition Width="84*" />
                <ColumnDefinition Width="78*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="84*" />
                <RowDefinition Height="343*" />
                <RowDefinition Height="30*" />
            </Grid.RowDefinitions>

            <Button x:Name="CancelButton" Content="Cancel" Grid.Column="2" Grid.Row="2" Margin="5" Command="{Binding SettingsCommand, Mode=OneWay}"/>
                <!--<i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cmd:EventToCommand Command="{Binding Path=SettingsCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>-->
            <!--</Button>-->
            <Button Content="Complete" Name="CompleteButton" Grid.Row="2" Grid.Column="1" Margin="5" Command="{Binding CompleteCommand, Mode=OneWay}" />
                <!--<i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <cmd:EventToCommand Command="{Binding Path=CompleteCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>-->
            <!--</Button>-->
            <GroupBox Header="Library Options:" Grid.ColumnSpan="3" Margin="5,0">
                <Grid HorizontalAlignment="Left" Name="grid1" VerticalAlignment="Top" Width="394" Height="67" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="28*" />
                        <RowDefinition Height="28*" />
                        <RowDefinition Height="2*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="144*" />
                        <ColumnDefinition Width="166*" />
                        <ColumnDefinition Width="84*" />
                    </Grid.ColumnDefinitions>
                    <Label Content="Library Name:"   Name="LibName" VerticalAlignment="Center"  Grid.Row="0" Grid.Column="0" FontWeight="Black" />
                    <TextBox Text="{Binding Source={x:Static Properties:Settings.Default}, Path=LibraryName, Mode=TwoWay}" VerticalAlignment="Center" Grid.Column="1" Grid.Row="0" />
                    <Label Content="Library Path:"  Name="LibPath" VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" FontWeight="Bold" />
                    <TextBox  Text="{Binding Source={x:Static Properties:Settings.Default}, Path=LibraryDir, Mode=TwoWay}" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1" />
                    <Button Content="..." Grid.Column="2" Grid.Row="1" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2" Command="{Binding BrowseCommand, Mode=OneWay}" CommandParameter="Library">
                        <!--<i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=BrowseCommand}" CommandParameter="Library" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>-->
                    </Button>
                </Grid>
            </GroupBox>
            <GroupBox Grid.ColumnSpan="3" Grid.Row="1" Header="Indexing Settings:" Margin="5,0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="28*" />
                        <RowDefinition Height="28*" />
                        <RowDefinition Height="28*" />
                        <RowDefinition Height="28*" />
                        <RowDefinition Height="28*" />
                        <RowDefinition Height="195*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="92*" />
                        <ColumnDefinition Width="164*" />
                        <ColumnDefinition Width="122*" />
                    </Grid.ColumnDefinitions>
                    <Label Content="Category:" Grid.Column="0" Grid.Row="0" Height="28" VerticalAlignment="Center"  FontWeight="Black" />
                    <Label Content="Path:" Grid.Column="0" Grid.Row="1" Height="28" VerticalAlignment="Center"  FontWeight="Black"/>
                    <Label Content="Extensions:" Grid.Column="0" Grid.Row="2" Height="28" VerticalAlignment="Center"  FontWeight="Black"/>
                    <ComboBox Grid.Column="1" Grid.Row="0" VerticalAlignment="Center" x:Name="CatCombo" SelectedItem="{Binding Path=CurrentCatItem}" ItemsSource="{Binding Path=CategoryList}" IsEnabled="{Binding Path=NewItemEnabled}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cmd:EventToCommand Command="{Binding Path=CatComboCommand}" CommandParameter="{Binding ElementName=CatCombo,Path=SelectedItem}"  />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ComboBox>
                    <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=CategoryPath}" IsEnabled="{Binding Path=NewItemEnabled}" />
                    <Button Grid.Column="2" Grid.Row="1" Content="..." HorizontalAlignment="Left" VerticalAlignment="Center" IsEnabled="{Binding Path=NewItemEnabled}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=BrowseCommand}" CommandParameter="Category" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <ComboBox Grid.Column="1" Grid.Row="2" IsEnabled="{Binding Path=ExtensionEnabled}" ItemsSource="{Binding Path=ExtensionList}" Text="{Binding Extensions}" IsEditable="True">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal">
                                    <CheckBox IsChecked="{Binding IsSelected}" Width="20" />
                                    <TextBlock Text="{Binding ExtensionName}" Width="100" />
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="DropDownClosed">
                                <cmd:EventToCommand Command="{Binding Path=ExtensionDropDownCommand}" CommandParameterValue="CLOSE"/>
                            </i:EventTrigger>
                            <i:EventTrigger EventName="DropDownOpened">
                                <cmd:EventToCommand Command="{Binding Path=ExtensionDropDownCommand}" CommandParameterValue="OPEN"/>
                            </i:EventTrigger>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cmd:EventToCommand Command="{Binding Path=ExtensionDropDownCommand}" CommandParameterValue="CHANGE"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ComboBox>
                    <Label Grid.Column="2" Grid.Row="2" Content="ext1;ext2;ext3..."></Label>
                    <Button Grid.Column="1" Grid.Row="3" Content="{Binding NewAddText, Mode=OneWay}" Margin="2,2,2,2" Width="48" HorizontalAlignment="Right" Command="{Binding AddCommand}">
                        <!--<i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=AddCommand}"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>-->
                    </Button>
                    <Button Grid.Column="2" Grid.Row="3" Content="Update" Margin="2,2,0,2" IsEnabled="{Binding Path=NewItemEnabled}" Width="48" HorizontalAlignment="Left">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=UpdateCommand}" CommandParameter="{Binding ElementName=dgSettings,Path=SelectedItem}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button Grid.Column="2" Grid.Row="3"  Margin="56,2,21,2" IsEnabled="{Binding Path=NewItemEnabled}" Content="Delete">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cmd:EventToCommand Command="{Binding Path=DeleteCommand}" CommandParameter="{Binding ElementName=dgSettings,Path=SelectedItem}"  />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <DataGrid Grid.Row="4" Grid.RowSpan="2" Grid.ColumnSpan="3" ItemsSource="{Binding Path=CategoryTable}" AutoGenerateColumns="false" x:Name="dgSettings" Margin="0,1,0,0" IsReadOnly="True">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Category" Binding="{Binding  Path=Name}" CanUserReorder="False" />
                            <DataGridTextColumn Header="Path" Binding="{Binding Path=Path}" CanUserReorder="False"/>
                            <DataGridTextColumn Header="Extensions" Binding="{Binding Path=Extensions}" Width="*" CanUserReorder="False" />
                        </DataGrid.Columns>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectionChanged">
                                <cmd:EventToCommand Command="{Binding Path=CatComboCommand}" CommandParameter="{Binding ElementName=dgSettings,Path=SelectedItem}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </DataGrid>
                </Grid>
            </GroupBox>
        </Grid>

    </Grid>

</UserControl>